package com.blb.community.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.blb.community.Utils.SnowflakeIdWorker;
import com.blb.community.mapper.ZyComplaintSuggestMapper;
import com.blb.community.pojo.ZyComplaintSuggest;
import com.blb.community.service.IZyComplaintSuggestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 投诉建议  服务实现类
 * </p>
 *
 * @author gch
 * @since 2023-12-05
 */
@Service
public class ZyComplaintSuggestServiceImpl extends ServiceImpl<ZyComplaintSuggestMapper, ZyComplaintSuggest> implements IZyComplaintSuggestService {
    @Autowired
    private ZyComplaintSuggestMapper zyComplaintSuggestMapper;
    @Override
    public void addComplaintSuggest(ZyComplaintSuggest zyComplaintSuggest) {
        zyComplaintSuggest.setCreateTime(LocalDateTime.now());
        SnowflakeIdWorker snow = new SnowflakeIdWorker(3L, 17L);
        zyComplaintSuggest.setComplaintSuggestId(snow.nextId());
        zyComplaintSuggestMapper.insert(zyComplaintSuggest);
    }

    @Override
    public List<ZyComplaintSuggest> findComplaintSuggestByUserId(Long userId) {
        return zyComplaintSuggestMapper.selectComplaintSuggestByUserId(userId);
    }
}
